<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/app.css">
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="../../datepicker/external/jquery/jquery.js"></script>
    <script type="text/javascript" src="/h5/js/all.js"></script>
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/framework7/1.6.5/css/framework7.ios.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/framework7/1.6.5/css/framework7.ios.colors.min.css" rel="stylesheet">

    <style>
        .img { padding:10px;border:0;border-top:2px solid #f5f5f5; }
        .img span { color:#f0f0f0; }
        /*末尾指引*/
        #zhiyin { width:100%;height:40px;
            border:0;line-height:40px;color:#aaaaaa;
            background:#e0e0e0;text-align:center;
            position:fixed;bottom:0;
        }
        #zhiyin button { padding:5px 10px;background:#fff;border:0; }
        #zhiyin .btnCurr { color:#fff;background:#0088cc; }
    </style>
</head>
<body style="overflow-y: auto;-webkit-overflow-scrolling: touch">
<!--
    制作者：九哥
    页面：发布订单页面
    时间：2019-05-24
-->





<!----------订单合同---------->
<div id="addOrderPage">
    <div id="addOrderTitle">
        <b class="title">订单合同</b>
        <img src="../../images/return.png"
             id="addOrderRtn" onclick="history.go(-1)">
    </div>
    <div style="height:1.593333rem"></div>
    <div id="addOrderDetail">
        <p class="topTitle">订单合同</p>
        <table class="productPicture">
            <tr>
                <td>订单合同扫描件 <br> 发单方上传：</td>
                <td class="right">
                    <div class="file">
                        <input type="file" id="file" name="img">
                    </div>
                </td>
            </tr>
        </table>
        <div class="img">
            <img src="../../images/toux01.png" width="100%" id="showFile">
            <input type="hidden" id="hideFile" value="">
            <!--<br><br><br><br>-->
            <!--发单方：-->
            <!--<span>法人盖章或签字</span>-->
            <!--<br><br><br><br>-->
            <!--合作方方：-->
            <!--<span>法人盖章或签字</span>-->
            <!--<br><br><br><br>-->
        </div>
        <p id="addOrderSubmit">
            <button class="addOrder" onclick="setContract()">确认发布</button>
        </p>
        <!--末尾指引-->
        <div style="height:50px;"></div>
        <div id="zhiyin">
            <button>订单资料</button>
            --
            <button class="btnCurr">面料清单</button>
            --
            <button>订单合同</button>
        </div>
    </div>
</div>
<input type="hidden" id="orderId" value="0">
<input type="hidden" id="nextSubmit" value="0">
<!----------订单合同---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../../js/app.js"></script>
<script type="text/javascript" src="../../js/imgUpload.js"></script>
<script type="text/javascript" src="../../js/alertMsg.js"></script>
<script type="application/javascript">
    (function(){
        $('#orderId')[0].value = getUrlParam('id');
        $('#nextSubmit')[0].value = getUrlParam('nextSubmit');
        initBtn();
    })();

    var order = new MC.Order.AddOrder();
    order.loadContract();
    /**
     * 初始化btn
     * */
    function initBtn(){
        var nextSubmit = $('#nextSubmit').val();
        var h = '';
        if (nextSubmit==0) {
            h += '<button class="btnCurr">订单资料</button>';
            h += '--';
            h += '<button class="btnCurr">订单合同</button>';
        } else {
            h += '<button class="btnCurr">订单资料</button>';
            h += '--';
            h += '<button class="btnCurr">面料清单</button>';
            h += '--';
            h += '<button class="btnCurr">订单合同</button>';
        }
        $('#zhiyin').html(h);
    }
    imgUpload2('file', '/api/member/upload/img');
    /**
     * 设置后台
     * */
    function setContract(){
        var userInfo = cacheGet('userInfo');
        var orderId = $('#orderId').val();
        var imgUrl = $('#hideFile').val();
        if (userInfo==null || userInfo.token=='undefined') {
            getErrMsg('没有登录！',''); return;
        }
        if (imgUrl=='' || imgUrl==null) {
            getAppErrMsg('合同扫描件没有上传！','',1000);
            return;
        }
        var data = {
            app_access:app_access,
            token:userInfo.token,
            type:userInfo.type,
            cate:userInfo.cate,
            orderId:orderId,
            img:imgUrl
        };
        $.ajax({
            url: getDomain() + 'contract/add',
            type:'post',
            data:data,
            success: function (res) {
                //console.log(res); return;
                if (res.code!=0) {
                    console.log(res.msg); return;
                }
                getAppErrMsg('发布成功！','',1000);
                setTimeout(function(){
                    window.location.href = '/h5/order.html';
                },1000);
            },
            error:function(){
                console.log('操作失败！'); return;
            }
        });
    }
    /**
     * 接口地址前缀
     * */
    function getDomain(){
        return '/api/home/release/';
    }
</script>
</html>